'use strict';

const mongoose = require('mongoose'),
    path = require('path'),
    mongoConfig = require('./env/mongo.json'),
    config = require('./config.js');

if (mongoConfig.mongodb.debug) {
    mongoose.set('debug', true);
}
var db = mongoose.connect(mongoConfig.mongodb.uri, mongoConfig.mongodb.options, function (err) {
    if (err) {
        console.error('Could not connect to MongoDB!');
        console.error(err);
        process.exit(-1);
    }
    else {
        console.log('Connected to MongoDB!');
    }
});

config.getGlobbedFiles('app/model/*.js').forEach(function (modelPath) {
    require(path.resolve(modelPath));
});